<template>
	<div class="journal-details i_maxW">
		<div v-for="item of details" :key="item.id">
			<div class="space-crumbs">
				<router-link to="/teach">名师中心</router-link>
				<span @click="goBack()"><i>></i>{{item.user_name}}</span>
				<span><i>></i>{{item.name}}</span>
			</div>
			<div class="j-details clear">
				<div class="j-details-l fl">
					<h3>{{item.name}}</h3>
					<div class="j-details-l-user">
						<span>
							<img :src="BASE_URL + item.avatar_path">
						</span>
						<span>{{item.user_name}}</span>
						<span>发表于  {{item.create_time}} </span>
					</div>
					<div class="j-details-l-cont" v-html="item.profile"></div>
				</div>
				<div class="j-details-r fr">
					<div class="j-details-r-h">
						<i class="ipng icon_mingshi_rizhi2"></i>
						<span>该老师的其它日志</span>
					</div>
					<ul>
						<template v-if="journalList.length !== 0">
							<li class="j-details-r-ls" v-for="item1 of journalList" :key="item1.id">
								<span class="name" @click="seeOtherJournal(item1)">{{ item1.name }}</span>
								<span class="time">{{item1.create_time}}</span>
							</li>
						</template>

						<li class="j-details-r-ls2" v-else>
							<span>暂无相关信息</span>
						</li>
					</ul>

				</div>
			</div>
		</div>
	</div>
</template>

<script>
	
	export default{
		data(){
			return {
				journalId:this.$route.query.id,
				details: null,
				journalList: [],

			}
		},
		created(){
			this.getdetails()
			this.getjournalList()
		},
		methods: {
			goBack(){
				this.$router.back(-1)
			},
			getdetails(){
				let success = (res =>{
					this.details = res.data;
				});
				this.$ajax({
					url: 'api/resource/journal',
					method: 'get',
					params: {
						id: this.journalId,
						data_type: 0
					},
					func: {success: success}
				})
			},
			getjournalList(){
				this.journalList = [];
				let success = (res =>{
					this.journalList = res.data;
				});
				this.$ajax({
					url: 'api/resource/journal',
					method: 'get',
					params: {
						create_id: this.$route.query.teacherId,
						status: 1,
						orderby: 'time',
						orderby_desc: 'DESC',
						authority: 1,
						page:1,
						size:10,
						not_id:this.journalId//排除当前的
					},
					func: {success: success}
				})
			},
			// 点击一个其他的日志
			seeOtherJournal(item){
				this.$router.push({ path: '/teach/see', query: { id: item.id, teacherId: this.$route.query.teacherId } });
			}
		}
	}
</script>